package com.z.redis.channel;

import com.z.redis.channel.epoll.EpollChannelOption;
import com.z.redis.channel.kqueue.KqueueChannelOption;
import com.z.redis.channel.select.NioSelectChannelOption;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.kqueue.KQueue;


public class DefaultChannelSelectStrategy implements ChannelSelectStrategy{
    /**
     * 自动选择最优的netty传输方式
     */
    @Override
    public LocalChannelOption select(){
        if(KQueue.isAvailable()){//检查是否支持KQueue
            return new KqueueChannelOption();
        }
        if(Epoll.isAvailable()){//检查是否支持Epoll
            return new EpollChannelOption();
        }
        return new NioSelectChannelOption();
    }
}
